package com.bitantenna.player;

import java.util.ArrayList;
import java.util.List;

import javax.swing.event.TableModelEvent;
import javax.swing.table.AbstractTableModel;

public abstract class ListTableModel extends AbstractTableModel {

	public List list = new ArrayList();

	public ListTableModel() {
		super();
	}

	protected void list(List l) {
		list=l;
		fireTableChanged(new TableModelEvent(this));
	}

	public void fireChanges() {
		fireTableChanged(new TableModelEvent(this,0,list.size()-1));		
	}

	@Override
	public Class<?> getColumnClass(int columnIndex) {
		return String.class;
	}

	@Override
	public int getColumnCount() {
		// 
		return list.size()>0 ? customInfo(list.get(0)).length :2;
	}

	public abstract String[] customHeader();

	abstract String[] customInfo(Object o);
	
	@Override
	public String getColumnName(int columnIndex) {
		return customHeader()[columnIndex];
	}

	@Override
	public int getRowCount() {	
		return list.size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {	
		return customInfo(list.get(rowIndex))[columnIndex];
	}

	@Override
	public boolean isCellEditable(int rowIndex, int columnIndex) {
		return false;
	}

	@Override
	public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
		
	
	}

}